import { defineStore } from "pinia";
import { post,get } from "@/utils/request";
import { ref } from 'vue'

export const useStudentDetailStore = defineStore('studentDetail',() => {
  let studentDetailData = ref({
    examLevel: '',
    examscore: '',
    scholarship: '',
    politicalAppearance: '',
    grades: '',
    volunteerDuration: '',
    competitionDescription: '',
    competitionPath: '',
    paperDescription: '',
    paperPath: '',
    scientificResearchDescription: '',
    Copyright: '',
    scientificResearchPath: '',
    disciplinaryText: '',
    graduationText: ''
  })
  // 展示详情页数据
  const studentDetailRequest = async (questionnaireId) => {
    console.log(questionnaireId)
    try{
      const response = await get('/student/listdetails',{
        questionnaireId:questionnaireId
      })
      console.log(response)
      
        studentDetailData.value = response.data
        console.log(studentDetailData.value)
      
    }catch(error){
      console.error(error)
    }
  }

  // 详情页编辑
  const changeStudentDetailRequest = async (changeStudentDetail) => {
    try{
      const response = await post('/student/edit',{
        changeStudentDetail
      })
    }catch(error){
      console.error(error)
    }
  }

  return {studentDetailData,studentDetailRequest,changeStudentDetailRequest}
})